package 序列化和反序列化;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class 反序列化 {
    public static void main(String[] args) {
        try (
                ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("prt\\src\\oops.txt"))
                ){
            //单个
            user us = (user)objectInputStream.readObject();
            System.out.println(us.getAge()+ us.getName());

            //多个
            List<user> list = (List<user>) objectInputStream.readObject();
            for (user user : list) {
                System.out.println(user.getName() + ":" + user.getAge());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
